import request from "@/utils/request"

//查询机构树（懒加载不返回isLeaf）
export function getOrganizationLazy(query) {
  return request({
    url: "/upms/organization/getOrganizationLazy",
    method: "get",
    params: query
  })
}

//查询机构树（懒加载返回isLeaf）
export function getLazyOrgTree(parentId) {
  return request({
    url: "/upms/organization/getLazyOrgTree/" + parentId,
    method: "get"
  })
}

export function getLazyLowerLevelOrgTree(parentId) {
  return request({
    url: "/upms/organization/getLazyLowerLevelOrgTree/" + parentId,
    method: "get"
  })
}

//查询机构树
export function getOrganTree(query) {
  return request({
    url: "/upms/organization/getOrgTree",
    method: "get",
    params: query
  })
}

//查询机构树下级机构或科室
export function LazyNodeTree(id) {
  return request({
    url: "/upms/organization/LazyNodeTree/" + id,
    method: "get"
  })
}

//查询科室树（懒加载）
export function getLazyTreeDept(query) {
  return request({
    url: "/basic/hisDept/getLazyTreeDept",
    method: "get",
    params: query
  })
}

//查询科室下级科室
export function getChildNodeLazy(id) {
  return request({
    url: "/basic/hisDept/getChildNodeLazy/" + id,
    method: "get"
  })
}

//初始化数据
export function initData(data) {
  return request({
    url: "/basic/hisDept/initOrgDept",
    method: "put",
    data
  })
}

//查询当前机构下是否存在科室
export function getDeptByOrganId(sysOrganizationId) {
  return request({
    url: "/basic/hisDept/getCountByOrganId/" + sysOrganizationId,
    method: "get"
  })
}

//查询当前科室是否存在下级科室
export function getCountHasChildren(hisDeptId) {
  return request({
    url: "/basic/hisDept/getCountHasChildren/" + hisDeptId,
    method: "get"
  })
}

export function list() {
  return request({
    url: "/basic/hisDeptDic/list",
    method: "get"
  })
}

//编辑科室
export function editDept(data) {
  return request({
    url: "/basic/hisDept",
    method: "put",
    data: data
  })
}

//新增科室
export function addDept(data) {
  return request({
    url: "/basic/hisDept",
    method: "post",
    data: data
  })
}

//根据科室id查询科室数据
export function getById(id) {
  return request({
    url: "/basic/hisDept/" + id,
    method: "get"
  })
}

//删除科室
export function deleteDept(id) {
  return request({
    url: "/basic/hisDept/" + id,
    method: "delete"
  })
}

//查询医护人员信息
export function medicalStaffList(query) {
  return request({
    url: "/basic/hisMedicalStaff/list",
    method: "get",
    params: query
  })
}

//根据机构id获取该机构的坐诊科室
export function getDeptIdListByOrgId(sysOrganizationId) {
  return request({
    url: `/basic/hisDept/getDeptIdListByOrgId/${sysOrganizationId}`,
    method: "get"
  })
}

// 查询挂号类别下拉
//查询挂号类别
export function getRegisterType(organId) {
  return request({
    url: `/his/hisRegCategoryInfo/getRegisterType/${organId}`,
    method: "get"
  })
}
